/**
 * @Author 韦建韩
 * @Date 2022/3/24
 */
package com.zczn.order_system.controller;

import com.zczn.order_system.constant.HttpCodeConstant;
import com.zczn.order_system.entity.dto.ResultDto;
import com.zczn.order_system.entity.pojo.Result;
import com.zczn.order_system.mapper.AdministratorsMapper;
import com.zczn.order_system.entity.Administrators;
import com.zczn.order_system.service.ServiceImpl.AdministratorsInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
@CrossOrigin
public class AdministratorInfoController {
  @Autowired
  AdministratorsInfoServiceImpl administratorsInfoService;

    @RequestMapping("login")
    public Result login(@RequestBody Administrators administrators){
      Result result = new Result();
        ResultDto resAdmin = administratorsInfoService.findInfoByAccount(administrators);
            result.convertDto(resAdmin);
            return result;
        }


    @RequestMapping("register")
    public Result register(@RequestBody Administrators administrators){
        Result result = new Result();
        administratorsInfoService.insertAdministrators(administrators);
        result.setCode(HttpCodeConstant.Field.Success.code);
        return result;
    }
}
